import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author yu
 * @date 2025年04月18日 23:38
 */
public class _20250405_03 {
    static List<List<Edge>> tree;
    static int[] depth;
    static int[][] parent;
    static long[][] dist;
    static int[] max1, max2, from1, from2;
    static int[] inTime, outTime;
    static int time = 0;
    static int LOG;

    static class Edge {
        int to;
        long weight;
        Edge(int to, long weight) {
            this.to = to;
            this.weight = weight;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        // 初始化树结构
        tree = new ArrayList<>(n + 1);
        for (int i = 0; i <= n; i++) {
            tree.add(new ArrayList<>());
        }

        // 读取边信息
        for (int i = 0; i < n - 1; i++) {
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            long d = scanner.nextLong();
            tree.get(u).add(new Edge(v, d));
            tree.get(v).add(new Edge(u, d));
        }

        // 预处理LCA和距离
        LOG = (int) (Math.log(n) / Math.log(2)) + 1;
        parent = new int[n + 1][LOG];
        dist = new long[n + 1][LOG];
        depth = new int[n + 1];
        inTime = new int[n + 1];
        outTime = new int[n + 1];

        // 第一次DFS预处理父节点和深度
        dfs(1, 0, 0);

        // 预处理二进制跳跃表
        for (int j = 1; j < LOG; j++) {
            for (int i = 1; i <= n; i++) {
                parent[i][j] = parent[parent[i][j - 1]][j - 1];
                dist[i][j] = dist[i][j - 1] + dist[parent[i][j - 1]][j - 1];
            }
        }

        // 预处理每个节点的最大路径
        max1 = new int[n + 1];
        max2 = new int[n + 1];
        from1 = new int[n + 1];
        from2 = new int[n + 1];
        dfsMax(1, 0);

        // 处理查询
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            int lca = lca(x, y);
            long d = getDistance(x, y, lca);
            long mx = getMax(x, lca);
            long my = getMax(y, lca);
            System.out.println(d + mx + my);
        }
    }

    static void dfs(int u, int p, long d) {
        parent[u][0] = p;
        dist[u][0] = d;
        depth[u] = depth[p] + 1;
        inTime[u] = ++time;
        for (Edge e : tree.get(u)) {
            if (e.to != p) {
                dfs(e.to, u, e.weight);
            }
        }
        outTime[u] = time;
    }

    static int lca(int u, int v) {
        if (depth[u] < depth[v]) {
            int temp = u;
            u = v;
            v = temp;
        }
        for (int i = LOG - 1; i >= 0; i--) {
            if (depth[u] - (1 << i) >= depth[v]) {
                u = parent[u][i];
            }
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (parent[u][i] != parent[v][i]) {
                u = parent[u][i];
                v = parent[v][i];
            }
        }
        return parent[u][0];
    }

    static long getDistance(int u, int v, int lca) {
        return getDist(u, lca) + getDist(v, lca);
    }

    static long getDist(int u, int anc) {
        long res = 0;
        for (int i = LOG - 1; i >= 0; i--) {
            if (depth[u] - (1 << i) >= depth[anc]) {
                res += dist[u][i];
                u = parent[u][i];
            }
        }
        return res;
    }

    static void dfsMax(int u, int p) {
        max1[u] = 0;
        max2[u] = 0;
        from1[u] = 0;
        from2[u] = 0;
        for (Edge e : tree.get(u)) {
            if (e.to == p) continue;
            dfsMax(e.to, u);
            int current = max1[e.to] + (int) e.weight;
            if (current > max1[u]) {
                max2[u] = max1[u];
                from2[u] = from1[u];
                max1[u] = current;
                from1[u] = e.to;
            } else if (current > max2[u]) {
                max2[u] = current;
                from2[u] = e.to;
            }
        }
    }

    static int getMax(int u, int lca) {
        if (u == lca) {
            return max1[u];
        }
        if (isAncestor(u, lca)) {
            int v = u;
            while (parent[v][0] != lca) {
                v = parent[v][0];
            }
            if (from1[lca] == v) {
                return max2[lca];
            } else {
                return max1[lca];
            }
        }
        return max1[u];
    }

    static boolean isAncestor(int u, int anc) {
        return inTime[anc] <= inTime[u] && outTime[u] <= outTime[anc];
    }
}
